<html>
<head><meta charset="utf-8"><title>Should I be able to use my own LLVM-12.0.0 with rustc? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html">Should I be able to use my own LLVM-12.0.0 with rustc?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235354527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235354527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235354527">(Apr 20 2021 at 14:41)</a>:</h4>
<p>Hi,</p>
<p>I've just built rustc using an LLVM-12.0.0 that I built myself. This is valid, right? I ask because I've got this test failure:</p>
<div class="codehilite"><pre><span></span><code>---- [codegen] codegen/alloc-optimisation.rs stdout ----

error: verification with &#39;FileCheck&#39; failed
status: exit status: 1
command: &quot;/opt/llvm-12.0.0-release-with-assertions/bin/FileCheck&quot; &quot;--input-file&quot; &quot;/home/vext01/source/rust/build/x86_64-unknown-linux-gnu/test/codegen/alloc-optimisation/alloc-optimisation.ll&quot; &quot;/home/vext01/sourc
e/rust/src/test/codegen/alloc-optimisation.rs&quot;
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/home/vext01/source/rust/src/test/codegen/alloc-optimisation.rs:10:17: error: CHECK-NEXT: is not on the line after the previous match
 // CHECK-NEXT: ret void
                ^
/home/vext01/source/rust/build/x86_64-unknown-linux-gnu/test/codegen/alloc-optimisation/alloc-optimisation.ll:25:2: note: &#39;next&#39; match was here
 ret void
 ^
/home/vext01/source/rust/build/x86_64-unknown-linux-gnu/test/codegen/alloc-optimisation/alloc-optimisation.ll:11:7: note: previous match ended here
start:
      ^
/home/vext01/source/rust/build/x86_64-unknown-linux-gnu/test/codegen/alloc-optimisation/alloc-optimisation.ll:12:1: note: non-matching line after previous match is here
 %0 = tail call i8* @__rust_alloc(i64 4, i64 4) #2
^

Input file: /home/vext01/source/rust/build/x86_64-unknown-linux-gnu/test/codegen/alloc-optimisation/alloc-optimisation.ll
Check file: /home/vext01/source/rust/src/test/codegen/alloc-optimisation.rs

-dump-input=help explains the following input dump.

Input was:
&lt;&lt;&lt;&lt;&lt;&lt;
         .
         .
         .
        20:
        21: &quot;_ZN5alloc5boxed12Box$LT$T$GT$3new17h86d95fc91cd13025E.exit&quot;: ; preds = %start
        22:  %2 = bitcast i8* %0 to i32*
        23:  store i32 %data, i32* %2, align 4
        24:  tail call void @__rust_dealloc(i8* nonnull %0, i64 4, i64 4) #2
        25:  ret void
next:10      !~~~~~~~ error: match on wrong line
        26: }
        27:
        28: ; Function Attrs: nounwind nonlazybind uwtable
        29: declare i32 @rust_eh_personality(i32, i32, i64, %&quot;unwind::libunwind::_Unwind_Exception&quot;*, %&quot;unwind::libunwind::_Unwind_Context&quot;*) unnamed_addr #0
        30:
         .
         .
         .
&gt;&gt;&gt;&gt;&gt;&gt;

------------------------------------------



failures:
    [codegen] codegen/alloc-optimisation.rs
</code></pre></div>
<p>I built LLVM as described <a href="https://github.com/rust-lang/rust/issues/60059#issuecomment-823302769">here</a>.</p>
<p>Should I raise an issue? Thanks.</p>



<a name="235354594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235354594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235354594">(Apr 20 2021 at 14:41)</a>:</h4>
<p>(The failure does not occur using the bundled LLVM)</p>



<a name="235354768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235354768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235354768">(Apr 20 2021 at 14:42)</a>:</h4>
<p>Rust uses a patched llvm (rust-lang/llvm-project). One of these patches teaches llvm about <code>__rust_alloc</code> and <code>__rust_dealloc</code>. Others fix miscompilations and stuff like that.</p>



<a name="235355272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355272">(Apr 20 2021 at 14:45)</a>:</h4>
<p>Gotcha. So I guess if I want a stable LLVM whose version won't change under my feet, then  I should manually compile the fork.</p>



<a name="235355385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355385">(Apr 20 2021 at 14:46)</a>:</h4>
<p>You should be fine compiling and running your own still. Distributions do exactly that.</p>



<a name="235355454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355454">(Apr 20 2021 at 14:46)</a>:</h4>
<p>Though you may or may not need to bring some of those patches in which is also something distributions do.</p>



<a name="235355502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355502">(Apr 20 2021 at 14:47)</a>:</h4>
<p>I'm going to need to run the test suite in a CI setup, so the tests need to pass.</p>



<a name="235355798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355798">(Apr 20 2021 at 14:48)</a>:</h4>
<p>Should I just choose a recent llvm-12 branch from your fork? e.g. <code>rustc/12.0-2021-04-15</code>.</p>



<a name="235355917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235355917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235355917">(Apr 20 2021 at 14:49)</a>:</h4>
<p><code>.gitmodules</code> in the rust repo shows the right branch. Currently it is <code>rustc/12.0-2021-04-15</code>.</p>



<a name="235359361"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235359361" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235359361">(Apr 20 2021 at 15:05)</a>:</h4>
<p>Sorry, one more query. For how long would I get away with using any given version from your fork?</p>
<p>For example, if i build the <code>rustc/12.0-2021-04-15</code> branch today, is it likely to still work with the latest rustc in say, a year or two's time, or is rustc quite dependent on a particular version?</p>



<a name="235360501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235360501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235360501">(Apr 20 2021 at 15:11)</a>:</h4>
<p>We support 2 or so major releases. Though it is recommended that people use the most recent llvm regardless because ecosystem may come to rely on e.g. soundness fixes only available in a more recent llvm version</p>



<a name="235360761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235360761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235360761">(Apr 20 2021 at 15:13)</a>:</h4>
<p>A good example of this are the <code>loop{}</code> miscompiles. Most code will work on llvm 10/11 but a crate written with 12 in mind may end up with a loop{} that's misoptimized under those older versions.</p>



<a name="235402462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235402462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235402462">(Apr 20 2021 at 19:37)</a>:</h4>
<p>Great. Thank you.</p>



<a name="235480484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235480484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235480484">(Apr 21 2021 at 09:33)</a>:</h4>
<blockquote>
<p>Rust uses a patched llvm (rust-lang/llvm-project). One of these patches teaches llvm about __rust_alloc and __rust_dealloc. Others fix miscompilations and stuff like that.</p>
</blockquote>
<p>So it's not just optimisations? rustc will in some situations, miscompile things with a stock llvm?</p>



<a name="235480748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235480748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235480748">(Apr 21 2021 at 09:35)</a>:</h4>
<p>correct</p>



<a name="235480808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235480808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235480808">(Apr 21 2021 at 09:36)</a>:</h4>
<p>(well, I think "llvm will miscompile things" is more accurate)</p>



<a name="235480868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235480868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235480868">(Apr 21 2021 at 09:36)</a>:</h4>
<p>I think we try pretty hard to upstream patches that fix miscompilations though</p>



<a name="235481750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235481750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235481750">(Apr 21 2021 at 09:45)</a>:</h4>
<p>I thought there was a policy to not add patches before they're accepted by upstream LLVM (though they might not be in the latest release yet)</p>



<a name="235481817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235481817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235481817">(Apr 21 2021 at 09:45)</a>:</h4>
<p>not that I'm aware of</p>



<a name="235481944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235481944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235481944">(Apr 21 2021 at 09:46)</a>:</h4>
<p>For the tiny PRs that I've submitted I used my system LLVM to speed up the initial compile time. But you might need to build the custom one if you get failing tests or other weird issues.</p>



<a name="235481987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235481987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235481987">(Apr 21 2021 at 09:47)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu</span> <span class="user-mention silent" data-user-id="223288">Edd Barrett</span> is building from source for a distro (or possibly a fork? I don't remember)</p>



<a name="235482184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235482184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235482184">(Apr 21 2021 at 09:48)</a>:</h4>
<p>Oh, okay</p>



<a name="235482432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235482432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235482432">(Apr 21 2021 at 09:51)</a>:</h4>
<p>Regarding the patching policy, I found this on <a href="https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html">https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html</a>: "Strongly prefer to upstream all patches to LLVM before including them in rustc. [...] Often we find bugs in the compiler and fix them upstream in LLVM. We'll want to pull fixes back to the compiler itself as they're merged upstream. [...] All features and bugfixes are upstream, but there's often some weird build-related patches that don't make sense to upstream which we have on our repositories."</p>



<a name="235482896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Should%20I%20be%20able%20to%20use%20my%20own%20LLVM-12.0.0%20with%20rustc%3F/near/235482896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Should.20I.20be.20able.20to.20use.20my.20own.20LLVM-12.2E0.2E0.20with.20rustc.3F.html#235482896">(Apr 21 2021 at 09:55)</a>:</h4>
<p>(I need to make changes to libLTO and was deciding if I should fork stock LLVM or the Rust fork)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>